#ifndef apiBulid_h
#define apiBilid_h

#include "main.h"

typedef struct
{
    double lat_degree;
    double lon_degree;
} COORDINATE; // coordinate

class C_apiBulidMap
{
private:
    /* data */
    C_apiCommunicate *p_C_apiCommunicate;
    std::thread thread1;
    std::thread thread2;
    std::vector<COORDINATE> originalCoordinateBuf;  // 保存原始坐标数据 
    std::vector<COORDINATE> earthCoordinateBuf;     // 保存世界坐标数据 
    std::vector<COORDINATE> relativeCoordinateBuf;  // 转换成厘米单位的相对位置坐标点
    float minClosedCurveDistance; // 闭合曲线最短距离，单位是厘米
    float mixCurveDistance;  // 用于判断行走距离大于设定值 单位是厘米
public:
    C_apiBulidMap(C_apiCommunicate *C_apiCommunicate);
    ~C_apiBulidMap();
    int getMessage(void);
    static void Callback(const MowerProtoPakg::localizationGNGGA& msg);
    void bulidMapLoop(void);
    int saveLongitudeLatitudeToFile(std::vector<std::string> buf); // 经纬度信息保存到文件里
    static void fifoSaveDate(double lat_degree, double lon_degree);
    bool getFifoDate(COORDINATE &tempCoordinate);
    void startLoop(void);
    int bulidMap(COORDINATE &pCoordinate, eCAL::protobuf::CPublisher<MowerProtoPakg::bulidMapLocalization> *p_ecal_bulidMapMessage);
    int saveCoordinate(COORDINATE &pCoordinate);
    void ecal_sandMessage(double lat_degree, double lon_degree, double start_lat_degree, double start_lon_degree, eCAL::protobuf::CPublisher<MowerProtoPakg::bulidMapLocalization> *p_ecal_bulidMapMessage);
    double calculateDistance(COORDINATE &point1, COORDINATE &point2);
};


#endif